package org.jeecg.modules.sssj.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import org.jeecg.modules.sssj.entity.SssjSwsj;
import org.jeecg.modules.sssj.mapper.SssjSwsjMapper;
import org.jeecg.modules.sssj.service.ISssjSwsjService;
import org.jeecg.modules.sssj.vo.SwsjVo;
import org.springframework.stereotype.Service;

import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: 实时数据-税务数据
 * @Author: jeecg-boot
 * @Date:   2022-06-13
 * @Version: V1.0
 */
@Service
public class SssjSwsjServiceImpl extends MppServiceImpl<SssjSwsjMapper, SssjSwsj> implements ISssjSwsjService {

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void insertFromSbxx(String tynsrsbh, String skssqq, String skssqz) {
        //先删除再插入
        LambdaQueryWrapper<SssjSwsj> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(SssjSwsj::getTynsrsbh, tynsrsbh);
        queryWrapper.eq(SssjSwsj::getSkssqq, skssqq);
        queryWrapper.eq(SssjSwsj::getSkssqz, skssqz);
        this.remove(queryWrapper);
        baseMapper.insertFromSbxx(tynsrsbh, skssqq, skssqz);
    }

    @Override
    public List<SwsjVo> selectNsrSwsj(String tynsrsbh, String skssqq, String skssqz) {
        return baseMapper.selectNsrSwsj(tynsrsbh, skssqq, skssqz);
    }

    @Override
    public String getNsrMaxSsqq(String tynsrsbh) {
        return baseMapper.getNsrMaxSsqq(tynsrsbh);
    }
}
